<!DOCTYPE html>
<html lang="en"
      xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
      layout:decorator="common/common">

<div class="centerView" data-type="widgets" th:fragment="content">
    <!-- 内容区域 -->
    <div class="tpl-content-wrapper" id="user" style="display:none;" v-show="departments.length != 0">
        <div class="row-content am-cf">
            <div class="row">
                <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                    <div class="widget am-cf">
                        <div class="widget-head am-cf">
                            <div class="widget-title  am-cf">职工列表</div>
                        </div>
                        <div class="widget-body  am-fr">

                            <div class="am-u-sm-12 am-u-md-6 am-u-lg-2">
                                <div class="am-form-group">
                                    <div class="am-btn-toolbar">
                                        <div class="am-btn-group am-btn-group-xs">
                                            <a type="button" class="am-btn am-btn-default am-btn-success"  href='user/user_create'><span
                                                    class="am-icon-plus"></span> 新增
                                            </a>
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <div class="am-u-sm-12 am-u-md-6 am-u-lg-3">
                                <div class="am-form-group tpl-table-list-select" style="width: 200px">
                                    <select data-am-selected="{btnSize: 'sm'}" id="department">
                                        <option value="0">部门</option>
                                        <option v-for="department in departments" v-bind:value="department.id">{{department.department}}</option>
                                    </select>
                                </div>
                            </div>
                            <div class="am-u-sm-12 am-u-md-6 am-u-lg-3">
                                <div class="am-form-group tpl-table-list-select" style="width: 200px">
                                    <select data-am-selected="{btnSize: 'sm'}" id="position">
                                        <option value="0">职位</option>
                                        <option v-for="position in positions" v-bind:value="position.id">{{position.position}}</option>
                                    </select>
                                </div>
                            </div>
                            <div class="am-u-sm-12 am-u-md-12 am-u-lg-3">
                                <div class="am-input-group am-input-group-sm tpl-form-border-form cl-p" style="width: 200px">
                                    <input type="text" class="am-form-field " placeholder="姓名" id="realname">
                                </div>
                            </div>

                            <div class="am-u-sm-12 am-u-md-12 am-u-lg-1">
                                <div class="am-input-group am-input-group-sm tpl-form-border-form cl-p">
                                <span class="am-input-group-btn">
                                    <button class="am-btn  am-btn-default am-btn-success tpl-table-list-field " type="button" v-on:click="getUser(1)">
                                        查询
                                    </button>
                                </span>
                                </div>
                            </div>

                            <div class="am-u-sm-12">
                                <table width="100%" class="am-table am-table-compact am-table-striped tpl-table-black "
                                       id="example-r">
                                    <thead>
                                    <tr>
                                        <th style="text-align: left">员工姓名</th>
                                        <th style="text-align: left">部门</th>
                                        <th style="text-align: left">职位</th>
                                        <th style="text-align: left">入职时间</th>
                                        <th style="text-align: left">上次登录时间</th>
                                        <th style="text-align: left">操作</th>
                                    </tr>
                                    </thead>
                                    <tbody v-if="userList.length == 0" >
                                        <tr>
                                            <td colspan="6" align="center">暂无数据</td>
                                        </tr>
                                    </tbody>
                                    <tbody v-else>
                                    <tr class="gradeX" v-for="user in userList">
                                        <td>{{user.realname}}</td>
                                        <td v-for="department in departments" v-if="department.id == user.departmentId">
                                            {{department.department}}
                                        </td>
                                        <td v-for="position in positions" v-if="position.id == user.positionId">
                                            {{position.position}}
                                        </td>
                                        <td>{{user.createTime}}</td>
                                        <td v-if="user.lastLoginTime != null">{{user.lastLoginTime}}</td>
                                        <td v-else>未登录</td>
                                        <td>
                                            <div class="tpl-table-black-operation">
                                                <a :href="'/projectoa/user/edit/' + user.id ">
                                                    <i class="am-icon-pencil" ></i> 编辑
                                                </a>
                                                <a :href="'/projectoa/user/userinfo/' + user.id">
                                                    <i class="am-icon-file-text" ></i> 详情
                                                </a>
                                                <a class="tpl-table-black-operation-del" v-on:click="deleteUser" :id="'delete_' + user.id">
                                                    <i class="am-icon-trash"></i> 删除
                                                </a>
                                                <a v-on:click="reverseUser" :id="'reverse_' + user.id">
                                                    <i class="am-icon-refresh"></i> 重置密码
                                                </a>
                                                <a v-on:click="setBest" :id="'set' + user.id" :id="'best_' + user.id">
                                                    <i class="am-icon-user"></i> 设为最佳员工
                                                </a>
                                            </div>
                                        </td>
                                    </tr>

                                    <!-- more data -->
                                    </tbody>
                                </table>
                            </div>
                            <div class="am-u-lg-12 am-cf" v-if="pageInfo.pages != 1">

                                <div class="am-fr">
                                    <ul class="am-pagination tpl-pagination">

                                        <li><a v-on:click="getUser(1)" >首页</a></li>

                                        <li >
                                            <a v-on:click="getUser(pageInfo.prePage)" v-if="!pageInfo.isFirstPage">«</a>
                                            <a v-else>«</a>
                                        </li>

                                        <!--<li class="am-active"><a href="#">1</a></li>-->
                                        <li v-for="n in pageInfo.pages" v-if="pageNum != n"><a v-on:click="getUser(n)">{{n}}</a></li>
                                        <li class="am-active" v-else><a v-on:click="getUser(n)">{{n}}</a></li>

                                        <li >
                                            <a v-on:click="getUser(pageInfo.nextPage)" v-if="!pageInfo.isLastPage">»</a>
                                            <a v-else>»</a>
                                        </li>

                                        <li><a v-on:click="getUser(pageInfo.pages)" >尾页</a></li>
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script th:src="@{/js/user.js}"></script>
    <script>
        $(document).ready(function() {
            $('#userA').attr('class','active');
        });
    </script>
</div>

</html>